include layout/header.jade
div.page-content
    div#wide.modal.fade(role="basic")
        div.modal-dialog.modal-wide
            div.modal-content
                div.modal-header
                    button.close(type="button",data-dismiss="modal")
                    h4 添加题目
                div.modal-body.row
                    div.col-md-10.col-md-offset-1
                        form#queform.form-horizontal(role="form")
                            div.form-group
                                label.control-label.col-md-2 题目
                                div.col-md-8
                                    textarea.form-control(placeholder='标签',name='name')
                            div.form-group
                                label.control-label.col-md-2 选项1
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项2
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项3
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项4
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项5
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项6
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项7
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                            div.form-group
                                label.control-label.col-md-2 选项8
                                div.col-md-8
                                    input.form-control(placeholder='标签',name='answer[]')
                div.modal-footer
                    div.col-md-10.col-md-offset-1
                        div.col-md-8.col-md-offset-2
                            button.btn.green(type="button",data-dismiss="modal") 取消
                            button#save.btn.green(type="submit") 保存
    div.modal-header
        h4.modal-title 添加标签
    form.form-horizontal(role="form",action="save",method="post")
        div.modal-body.row
            div.col-md-10.col-md-offset-1
                div.form-group
                    label.control-label.col-md-2 调查名称
                    div.col-md-8
                        input(type='hidden',name='id',value='#{discuss._id}')
                        input.form-control(placeholder='标签',name='name',value='#{discuss.name}',check-type="required",data-required="1" )
                div.form-group.videoform
                    label.control-label.col-md-2 题目
                    div.col-md-8
                        div.portlet.box.blue
                            div.portlet-title
                                div.caption 题目
                                div.actions
                                    a.btn.btn-success(data-toggle="modal",href="#wide") 添加标签
                            div#content.portlet-body
                                -var n = 0
                                each val in discuss.content
                                    div.alert.alert-warning
                                        div.row
                                            div.col-md-10
                                                span 问题:#{val.name}
                                                br
                                                each item in val.answer
                                                    span #{item}
                                                    br
                                                    input(type="hidden",name="content[answer][#{n}][]",value="#{item}")
                                            div.col-md-2
                                                button.btn.red.delete(type="button") 删除
                                            input(type="hidden",name="content[name][]",value="#{val.name}")
                                            -n=n+1
        div.modal-footer
            div.col-md-10.col-md-offset-1
                div.col-md-8.col-md-offset-2
                    a.btn.green(href="./") 取消
                    button.btn.green(type="submit") 保存
script(type='text/javascript').
      aoColumnDefs = [];
include layout/footer.jade
script(src="http://tinymce.cachefly.net/4.1/tinymce.min.js")
script(type='text/javascript').
    $(document).ready(function(){
        $("form").validation();
        var allcount = 0;
        $("#save").click(function(){
            var node = $("<div class='col-md-10'></div>");
            var list = $("#queform").serializeArray();
            for(var i in list)
                {
                    if(list[i].name=="name"){
                        node.append("<input type='hidden' name='content[name][]' value='"+list[i].value+"'/>");
                        node.append("<span>问题:"+list[i].value+"</span></br>");
                    }else if(list[i].value != ""){
                        node.append("<input type='hidden' name='content[answer]["+allcount+"][]' value='"+list[i].value+"'/>");
                        node.append("<span>"+list[i].value+"</span></br>");
                    }
                }
                
                var alert = $("<div class='alert alert-warning'></div>").append($("<div class='row'></div>").append(node));
                node.after("<div class='col-md-2'><button class='btn red delete' type='button'>删除</button></div>");
                    $("#content").append(alert);
                    allcount++;
                    $("#wide").modal('hide');
                    $("#queform")[0].reset();
            });
        $("#content").on('click','.delete',function(){
                $(this).parent().parent().parent().remove();
                
            });

    });
